<script setup>
import {onMounted, ref} from 'vue';
import {useRoute} from 'vue-router';
import router from '@/router/index.js';

// 路由路径 login register
const pathType = ref('');

const routeTo = (path) => {
  pathType.value = path;
  router.push({name: path});
}

onMounted(() => {
  pathType.value = useRoute().path.split('/')[2];
})
</script>

<template>
  <el-container>
    <el-header>
      <div class="logo_box">
        <img class="logo_img" src="/image/logo.png" alt="">
        <span class="logo_text">华绣瑰宝</span>
      </div>
      <div class="btn_box">
        <button class="btn_login" :class="pathType==='login'?'btn_click':''"
                @click="routeTo('login')">登录
        </button>
        <button class="btn_register" :class="pathType==='register'?'btn_click':''"
                @click="routeTo('register')">注册
        </button>
      </div>
    </el-header>
    <el-main>
      <div class="left_box">
        <div class="img_box">
          <img class="auth_bg" src="/image/auth_bg.jpg" alt="">
        </div>
      </div>
      <div class="right_box">
        <el-card>
          <RouterView></RouterView>
        </el-card>
      </div>
    </el-main>
    <el-footer>
      <p>
        <a href="#"><span>帮助中心</span>|</a>
        <a href="#"><span>服务支持</span>|</a>
        <a href="#"><span>售后服务</span>|</a>
        <a href="#"><span>服务网点</span>|</a>
        <a href="#"><span>线下门店</span>|</a>
        <a href="#"><span>申请商家</span>|</a>
        <a href="#"><span>加入我们</span>|</a>
        <a href="#"><span>关于我们</span>|</a>
        <a href="#"><span>友情链接</span></a>
      </p>
      <p>Copyright © 商城名称 2020-2050</p>
    </el-footer>
  </el-container>
</template>

<style scoped lang="scss">
.el-container {
  .el-header {
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 50px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);

    .logo_box {
      display: flex;
      align-items: center;

      .logo_img {
        height: 30px;
        border-radius: 10px;
      }

      .logo_text {
        margin-left: 5px;
        font-family: PMZDCuShuSong,serif;
        font-weight: bold;
      }
    }

    .btn_box {
      width: 30%;
      display: flex;
      gap: 10px;

      .btn_login {
        width: 60px;
        height: 27px;
        border: solid 1px var(--cx-color1);
        border-radius: 4px;
        cursor: pointer;
        background: transparent;
        color: var(--cx-color1);
      }

      .btn_register {
        width: 60px;
        height: 27px;
        border: solid 1px var(--cx-color1);
        border-radius: 4px;
        cursor: pointer;
        background: transparent;
        color: var(--cx-color1);
      }

      .btn_click {
        background: var(--cx-color1);
        color: #fff;
      }
    }
  }

  .el-main {
    padding-top: 70px;
    display: flex;

    .left_box {
      width: 50%;
      padding-left: 140px;

      .img_box {
        width: 415px;
        height: 450px;
        overflow: hidden;

        .auth_bg {
          width: 450px;
          height: 100%;
        }
      }
    }

    .right_box {
      width: 50%;
      padding-right: 140px;
      position: relative;

      .el-card {
        width: 350px;
        height: 400px;
        position: absolute;
        left: 40%;
        top: 50%;
        transform: translate(-50%, -50%);
      }
    }
  }

  .el-footer {
    position: absolute;
    bottom: 0;
    height: 100px;
    width: 100%;
    text-align: center;
    color: #8c8c8e;
    background-color: #2e2e41;

    p:first-child {
      margin-top: 20px;

      a {
        text-decoration: none;
        color: #8c8c8e;
      }

      span {
        margin-left: 5px;
        margin-right: 5px;
      }
    }

    p:last-child {
      margin-top: 20px;
      font-size: 13px;
    }
  }
}
</style>